﻿<%@ WebHandler Language="C#" Class="ContractMgr" %>

using System;
using System.Web;
using System.Text;

public class ContractMgr : AjaxHandlerBase
{
    public override void RequestProcess(HttpContext context)
    {
        try
        {
            switch (context.Request["op"].ToLower())
            {
                case "getlist":
                    GetList(context);
                    break;
            }
        }
        catch(Exception e)
        {
            context.Response.Write("{success:0,msg:'服务器执行错误！错误原因：" + e.Message.Replace("'", "\"") + "',data:''}");
        }
    }

    private void GetList(HttpContext context)
    {
        StringBuilder listStr = new StringBuilder();
        for (int i = 0; i < 50; i++)
        {
            listStr.AppendFormat("<ul class=\"x-multigrid-row\" id=\"{0}\">", "x_" + i);
            listStr.Append("<li><div>");
            listStr.Append("<dl><dt>地址：</dt><dd style=\"color:#006699;font-weight:bold;\">高青路2861弄109号602</dd><dt>公司：</dt><dd>易居臣信</dd><dt>标的：</dt><dd style=\"color:#ff0000;\">250万</dd><dt>下家客户：</dt><dd>杨万均</dd></dl>");
            listStr.Append("<dl><dt>区域：</dt><dd>浦东 世博板块 90平方米</dd><dt>签约人：</dt><dd>赵永华</dd></dl>");
            listStr.Append("<dl><dt>编号：</dt><dd>CXSH-M-0000000020</dd><dt>成交时间：</dt><dd style=\"color:#bbb;\">2010-10-1 8:20:16<dd><dt>客源门店：</dt><dd>浦东一店(a)A组</dd></dl>");
            listStr.Append("</div></li>");
            listStr.AppendFormat("<li class=\"x-multigrid-hide\"><div>");
            listStr.Append("<dl><dt>上家点数:</dt><dd>浦东一店A(a)</dd><dt>组业务员:</dt><dd>陈玉功 1.0点</dd><dt>店长:</dt><dd>何基锋；<dd><dt>高经:</dt><dd>王伟；</dd><dt>区经:</dt><dd>陈杰</dd></dl>");
            listStr.Append("<dl><dt>上家点数:</dt><dd>浦东一店A(a)</dd><dt>组业务员:</dt><dd>陈玉功 1.0点</dd><dt>店长:</dt><dd>何基锋；<dd><dt>高经:</dt><dd>王伟；</dd><dt>区经:</dt><dd>陈杰</dd></dl>");
            listStr.Append("<dl><dt>上家点数:</dt><dd>浦东一店A(a)</dd><dt>组业务员:</dt><dd>陈玉功 1.0点</dd><dt>店长:</dt><dd>何基锋；<dd><dt>高经:</dt><dd>王伟；</dd><dt>区经:</dt><dd>陈杰</dd></dl>");
            listStr.Append("</div></li>");
            listStr.Append("</ul>");
        }

        context.Response.Write("{success:1,msg:'',data:{html:'" + listStr.ToString() + "',count:300}}");
    }

    private string createHtmlElement(string elName,string innderHTML, string id,string className, string style, string config)
    {
        StringBuilder el = new StringBuilder();
        el.AppendFormat("<{0}", elName.ToLower());

        if (id.Trim() != "")
        {
            el.AppendFormat(" id=\"{0}\"", id);
        }
        if (className.Trim() != "")
        {
            el.AppendFormat(" class=\"{0}\"", className);
        }
        if (style.Trim() != "")
        {
            el.AppendFormat(" style=\"{0}\"", style);
        }
        if (config.Trim() != "")
        {
            el.AppendFormat(" {0}", config);
        }


        if (elName == "input" || elName.ToLower() == "img")
        {
            el.Append("/>");
        }
        else
        {
            el.AppendFormat(">{0}</{1}>", innderHTML, elName.ToLower());
        }

        return el.ToString();
    }

}